
using System;
using System.Collections.Generic;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

namespace XFGameFramework
{
    [Serializable]
    public class TreeViewStateInfo 
    {
        public int id;

#if UNITY_6000_2_OR_NEWER

        public TreeViewState<int> treeViewState;

#else
        public TreeViewState treeViewState;
#endif

#if UNITY_6000_2_OR_NEWER
        public TreeViewStateInfo(int id,TreeViewState<int> treeViewState) 
#else 
        public TreeViewStateInfo(int id,TreeViewState treeViewState)
#endif

        {
            this.id = id;
            this.treeViewState = treeViewState;
        } 
    }
     
    [Serializable]
    public class TreeViewStateGroup  
    {

        [SerializeField]
        private List<TreeViewStateInfo> treeViewStates = new List<TreeViewStateInfo>();

#if UNITY_6000_2_OR_NEWER

        public TreeViewState<int> Get(int hash_code)

#else 
        public TreeViewState Get(int hash_code)
#endif

        {

            foreach (var item in treeViewStates)
            {
                if (item.id == hash_code) 
                    return item.treeViewState;
            }
#if UNITY_6000_2_OR_NEWER
            TreeViewState<int> treeViewState = new TreeViewState<int>();
#else
            TreeViewState treeViewState = new TreeViewState();
#endif

            treeViewStates.Add(new TreeViewStateInfo(hash_code,treeViewState)); 
            return treeViewState;
        }

    }

}

